package cn.strive.eams.audit.controller;

import cn.strive.eams.audit.pojo.dto.AuditPassParam;
import cn.strive.eams.audit.pojo.dto.AuditQuery;
import cn.strive.eams.audit.pojo.vo.AuditVO;
import cn.strive.eams.audit.service.AuditService;
import cn.strive.eams.base.response.JsonResult;
import cn.strive.eams.busRequire.pojo.entity.BusRequire;
import cn.strive.eams.busRequire.pojo.vo.BusRequireVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/v1/audit")
@Api(tags = "审批管理")
@Slf4j
public class AuditController {

    @Autowired
    AuditService auditService;

    @GetMapping("/select")
    @ApiOperation(value = "查询审批项")
    public JsonResult select(AuditQuery auditQuery) {
        log.info("查询审批项:auditQuery={}", auditQuery);
        List<AuditVO> list = auditService.selectAll(auditQuery);
        return JsonResult.ok(list);
    }

    @GetMapping("/select/busrequire/{auditId}")
    @ApiOperation(value = "查询具体的车辆申请的内容")
    public JsonResult selectBusRequire(@PathVariable Long auditId) {
        log.info("查询具体的车辆申请的内容:auditId={}", auditId);
        List<BusRequireVO> list = auditService.selectBusRequire(auditId);
        return JsonResult.ok(list);
    }

    @PostMapping("/busrequirePass")
    @ApiOperation(value = "车辆申请通过")
    public JsonResult busRequirePass(AuditPassParam auditPassParam) {
        log.info("车辆申请通过:auditPassParam={}", auditPassParam);
        auditService.busRequirePass(auditPassParam);
        return JsonResult.ok();
    }
}
